#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'libb@anchent.com'

import os
import time
import random
from multiprocessing import Process, Lock


def download_task(name):
    # lock.acquire()
    download_time = random.randint(5, 10)
    time.sleep(download_time)
    print("download_task name:{}, download_time:{}".format(name, download_time))
    # lock.release()


lock = Lock()
if __name__ == '__main__':
    start = time.time()
    process_list = []
    for i in range(10):
        p = Process(target=download_task, args=(i,))
        p.start()
        process_list.append(p)

    for j in process_list:
        j.join()
    end = time.time()
    print("python_lock total cost time :{}".format(end - start))
